﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DKSMathEditor
{
    public partial class DKSMathEditor : UserControl
    {
        public DKSMathEditor()
        {
            InitializeComponent();
            this.btCode.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(this.btCode_ItemClick);
        }

        public event EventHandler ViewCodeClick;

        public string textResult()
        {
            return editer.pub_GetXML(false); 
        }

        public void LoadXML(string xml)
        {
            editer.pub_LoadXML(xml);
        }

        public bool ViewCode { get; set; }

        private void btundo_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_Undo();
        }

        private void btredo_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_Redo();
        }

        private void btPi_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertPi();
        }

        private void btsin_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertLuonggiac("sin");
        }

        private void btcos_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertLuonggiac("cos");
        }

        private void bttan_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertLuonggiac("tan");
        }

        private void btctg_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertLuonggiac("cot");
        }

        private void btasin_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertLuonggiac("arcsin");
        }

        private void btacos_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertLuonggiac("arccos");
        }

        private void btatan_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertLuonggiac("arctan");
        }

        private void btsinh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertLuonggiac("sinh");
        }

        private void btcosh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertLuonggiac("cosh");
        }

        private void btanh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertLuonggiac("tanh");
        }

        private void btasinh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertLuonggiac("arcsinh");
        }

        private void btacosh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertLuonggiac("arccosh");
        }

        private void atanh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertLuonggiac("arctanh");
        }

        private void btsqrt_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertSqrt();
        }

        private void btsqrtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertRoot();
        }

        private void btsqrn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertSuperScript();
        }

        private void btfrac_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertFraction();
        }

        private void btlna_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertLuonggiac("ln");
        }

        private void btloga_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertLuonggiac("log");
        }

        private void btexp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            editer.pub_InsertE();
        }

        private void btCode_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (this.ViewCodeClick != null)
                this.ViewCodeClick(this, e);
        }
    }
}
